package edu.scu.declaresys.vo;

import java.util.Date;

import edu.scu.declaresys.dao.util.Column;
import edu.scu.declaresys.dao.util.FieldWalker;
import edu.scu.declaresys.dao.util.Table;


/**
 * 
 * @author: zt
 * @since : 2013-7-3
 */
@Table(code=Project.T_TABLE)
public class Project implements java.io.Serializable
{
	private static final long	serialVersionUID	= 3117957272324154144L;
	//
	// table column name.
	//
	public static final String	T_TABLE					= "project";
	public static final String	T_ID					= "id";
	public static final String	T_AREA_COUNTY_ID		= "areaCountyId";
	public static final String	T_AREA_CITY_ID			= "areaCityId";
	
	
	/**
	 * 以下界面不管
	 */
	public static final String	T_DECLARE_USER_ID		= "declareUserId";
	public static final String	T_COUNTY_REC_USER_ID	= "countyRecUserId";
	public static final String	T_CITY_REC_USER_ID		= "cityRecUserId";
	public static final String	T_PROVINCE_REC_USER_ID	= "provinceRecUserId";
	public static final String	T_AUDIT_USER_ID			= "auditUserId";
	public static final String	T_STATE					= "state";
	public static final String	T_LEVEL					= "level";
	public static final String	T_UNIT_NAME				= "unitName";
	public static final String	T_YEAR					= "year";
	/**
	 * 以下界面要管
	 */
	public static final String	T_PROJECT_CLASS_ID		= "projectClassId";
	public static final String	T_NAME					= "name";
	public static final String	T_PROJECT_FILENO		= "projectFileno";
	public static final String	T_LEGAL_MAN				= "legalMan";
	public static final String	T_TECH_LEADER			= "techLeader";
	public static final String	T_FUND_TYPE				= "fundType";
	public static final String	T_GRANT_FUNDS			= "grantFunds";
	public static final String	T_OTHER_FUNDS			= "otherFunds";
	public static final String	T_SELF_RAISED_FUNDS		= "selfRaisedFunds";
	public static final String	T_TOTAL_FUNDS			= "totalFunds";
	public static final String	T_COUNTY_REC_FILENO		= "countyRecFileno";
	public static final String  T_CITY_REC_FILENO		= "cityRecFileno";
	public static final String	T_INTRO					= "intro";
	
	/**
	 * 以下界面不管
	 */
	public static final String	T_CREATE_TIME			= "createTime";
	public static final String	T_COMMIT_TIME			= "commitTime";
	public static final String	T_COUNTY_REC_TIME		= "countyRecTime";
	public static final String	T_CITY_REC_TIME			= "cityRecTime";
	public static final String	T_PROVINCE_REC_TIME		= "provinceRecTime";
	public static final String	T_AUDIT_TIME			= "auditTime";
	//
	// Project states.
	//
	public static final int		STATE_NULL							= -1;
	
	public static final int		STATE_DRAFT							= 1;
	public static final int		STATE_UNRCMD_COUNTY					= 2;
	public static final int		STATE_UNRCMD_CITY					= 3;
	public static final int		STATE_COUNTY_REQUEST_CANCEL_RCMD	= 10;
	public static final int		STATE_UNRCMD_PROVINCE				= 4;
	public static final int		STATE_CITY_REQUEST_CANCEL_RCMD		= 11;
	/**
	 * 请求修改状态
	 */
	public static final int		STATE_REQUEST_MODIFY		= 9;
	/**
	 * 申报人可修改
	 */
	public static final int		STATE_UNAUDIT_MODIFIABLE	= 5;
	/**
	 * 申报人不可修改
	 */
	public static final int		STATE_UNAUDIT_UNMODIFIABLE	= 6;
	
	public static final int		STATE_PASSED				= 7;
	/**
	 * 取消推荐后，审批未通过都将进入该状态。该状态下项目申报信息只有查看，
	 * 不能修改。
	 */
	public static final int		STATE_REJECTED				= 8;
	
	//
	//
	//
	public static final int YEAR_NULL = -1;
	
	
	
	//
	// 项目资金
	//
	public static final int		FUND_THREE_CITY				= 1;
	public static final String	FUND_THREE_CITY_NAME		= "三州开发资金";
	public static final int		FUND_UNDEVOLOPED_AREA		= 2;
	public static final String	FUND_UNDEVOLOPED_AREA_NAME	= "支持不发达地区发展资金";

	//
	// Fields
	//
	@Column(code=T_ID)
	private Integer	id;
	
	@Column(code=T_AREA_COUNTY_ID)
	private Integer areaCountyId;
	
	@Column(code=T_AREA_CITY_ID)
	private Integer areaCityId;
	
	@Column(code=T_PROJECT_CLASS_ID)
	private Integer	projectClassId;
	
	
	@Column(code=T_DECLARE_USER_ID)
	private Integer	declareUserId;
	
	@Column(code=T_COUNTY_REC_USER_ID)
	private Integer	countyRecUserId;
	
	@Column(code=T_CITY_REC_USER_ID)
	private Integer	cityRecUserId;
	
	@Column(code=T_PROVINCE_REC_USER_ID)
	private Integer	provinceRecUserId;
	
	@Column(code=T_AUDIT_USER_ID)
	private Integer	auditUserId;
	
	@Column(code=T_NAME)
	private String	name;
	
	@Column(code=T_YEAR)
	private Integer	year;
	
	@Column(code=T_STATE)
	private Integer	state;
	
	/**
	 * 项目级别，由地区级别判断.
	 */
	@Column(code=T_LEVEL)
	private Integer level;
	
	@Column(code=T_PROJECT_FILENO)
	private String	projectFileno;
	
	@Column(code=T_LEGAL_MAN)
	private String	legalMan;
	
	@Column(code=T_TECH_LEADER)
	private String	techLeader;
	
	@Column(code=T_UNIT_NAME)
	private String	unitName;
	
	@Column(code=T_FUND_TYPE)
	private Integer fundType;
	
	@Column(code=T_GRANT_FUNDS)
	private Long	grantFunds;
	
	@Column(code=T_OTHER_FUNDS)
	private Long	otherFunds;
	
	@Column(code=T_SELF_RAISED_FUNDS)
	private Long	selfRaisedFunds;
	
	@Column(code=T_TOTAL_FUNDS)
	private Long	totalFunds;
	
	@Column(code=T_COUNTY_REC_FILENO)
	private String	countyRecFileno;
	
	@Column(code=T_CITY_REC_FILENO)
	private String	cityRecFileno;
	
	@Column(code=T_INTRO)
	private String	intro;
	
	@Column(code=T_CREATE_TIME)
	private Date	createTime;
	
	@Column(code=T_COMMIT_TIME)
	private Date	commitTime;
	
	@Column(code=T_COUNTY_REC_TIME)
	private Date	countyRecTime;
	
	@Column(code=T_CITY_REC_TIME)
	private Date	cityRecTime;
	
	@Column(code=T_PROVINCE_REC_TIME)
	private Date	provinceRecTime;
	
	@Column(code=T_AUDIT_TIME)
	private Date	auditTime;
	//
	// References
	//
	private Area county;
	private Area city;
	private ProjectClass projectClass;
	private User declareUser;
	private User countyRecUser;
	private User cityRecUser;
	private User provinceRecUser;
	private User auditUser;
	//
	// Constructors
	//
	/** default constructor */
	public Project()
	{
	}
	


	public Project(Integer areaCountyId, Integer areaCityId,
			Integer projectClassId, Integer declareUserId,
			Integer countyRecUserId, Integer cityRecUserId,
			Integer provinceRecUserId, Integer auditUserId, String name,
			Integer year, Integer state, Integer level, String projectFileno,
			String legalMan, String techLeader, String unitName,
			Integer fundType, long grantFunds, long otherFunds,
			long selfRaisedFunds, long totalFunds, String countyRecFileno,
			String cityRecFileno, String intro, Date createTime,
			Date commitTime, Date countyRecTime, Date cityRecTime,
			Date provinceRecTime, Date auditTime)
	{
		super();
		this.areaCountyId = areaCountyId;
		this.areaCityId = areaCityId;
		this.projectClassId = projectClassId;
		this.declareUserId = declareUserId;
		this.countyRecUserId = countyRecUserId;
		this.cityRecUserId = cityRecUserId;
		this.provinceRecUserId = provinceRecUserId;
		this.auditUserId = auditUserId;
		this.name = name;
		this.year = year;
		this.state = state;
		this.level = level;
		this.projectFileno = projectFileno;
		this.legalMan = legalMan;
		this.techLeader = techLeader;
		this.unitName = unitName;
		this.fundType = fundType;
		this.grantFunds = grantFunds;
		this.otherFunds = otherFunds;
		this.selfRaisedFunds = selfRaisedFunds;
		this.totalFunds = totalFunds;
		this.countyRecFileno = countyRecFileno;
		this.cityRecFileno = cityRecFileno;
		this.intro = intro;
		this.createTime = createTime;
		this.commitTime = commitTime;
		this.countyRecTime = countyRecTime;
		this.cityRecTime = cityRecTime;
		this.provinceRecTime = provinceRecTime;
		this.auditTime = auditTime;
	}






	//
	// Override functions.
	//
	public String toString()
	{
		return FieldWalker.makeNonstaticFields(this, FieldWalker.WITHOUT_NULL);
	}
	
	@Override
	public int hashCode()
	{
		return id.hashCode();
	}

	@Override
	public boolean equals(Object obj)
	{
		if(this == obj)
		{
			return true;
		}
		if(obj == null)
		{
			return false;
		}
		if(!(obj instanceof Project))
		{
			return false;
		}
		//
		return this.id.equals(((Project)obj).id);
	}
	
	public String getStateName()
	{
		return getStateName(this.getState());
	}
	
	public static String getStateName(Integer state)
	{
		if(state == STATE_DRAFT)
		{
			return "草稿";
		}

			if(state == STATE_UNRCMD_COUNTY)
		{
			return "县级待推荐";
		}

			if(state == STATE_UNRCMD_CITY)
		{
			return "市级待推荐";
		}

			if(state == STATE_COUNTY_REQUEST_CANCEL_RCMD)
		{
			return "县级请求取消推荐";
		}

			if(state == STATE_UNRCMD_PROVINCE)
		{
			return "省级待推荐";
		}

		if(state == STATE_CITY_REQUEST_CANCEL_RCMD)
		{
			return "市级请求取消推荐";
		}
		if(state == STATE_REQUEST_MODIFY)
		{
			return "请求修改";
		}

		if(state == STATE_UNAUDIT_MODIFIABLE)
		{
			return "待审批可修改";
		}

		if(state == STATE_UNAUDIT_UNMODIFIABLE)
		{
			return "待审批不可修改";
		}
		if(state == STATE_PASSED)
		{
			return "已通过";
		}

		if(state == STATE_REJECTED)
		{
			return "已退回";
		}
		return null;
	}
	
	//
	// Getters and Setters
	//



	public Integer getId()
	{
		return id;
	}



	public void setId(Integer id)
	{
		this.id = id;
	}



	public Integer getAreaCountyId()
	{
		return areaCountyId;
	}



	public void setAreaCountyId(Integer areaCountyId)
	{
		this.areaCountyId = areaCountyId;
	}



	public Integer getAreaCityId()
	{
		return areaCityId;
	}



	public void setAreaCityId(Integer areaCityId)
	{
		this.areaCityId = areaCityId;
	}



	public Integer getProjectClassId()
	{
		return projectClassId;
	}



	public void setProjectClassId(Integer projectClassId)
	{
		this.projectClassId = projectClassId;
	}



	public Integer getDeclareUserId()
	{
		return declareUserId;
	}



	public void setDeclareUserId(Integer declareUserId)
	{
		this.declareUserId = declareUserId;
	}



	public Integer getCountyRecUserId()
	{
		return countyRecUserId;
	}



	public void setCountyRecUserId(Integer countyRecUserId)
	{
		this.countyRecUserId = countyRecUserId;
	}



	public Integer getCityRecUserId()
	{
		return cityRecUserId;
	}



	public void setCityRecUserId(Integer cityRecUserId)
	{
		this.cityRecUserId = cityRecUserId;
	}



	public Integer getProvinceRecUserId()
	{
		return provinceRecUserId;
	}



	public void setProvinceRecUserId(Integer provinceRecUserId)
	{
		this.provinceRecUserId = provinceRecUserId;
	}



	public Integer getAuditUserId()
	{
		return auditUserId;
	}



	public void setAuditUserId(Integer auditUserId)
	{
		this.auditUserId = auditUserId;
	}



	public String getName()
	{
		return name;
	}



	public void setName(String name)
	{
		this.name = name;
	}



	public Integer getYear()
	{
		return year;
	}



	public void setYear(Integer year)
	{
		this.year = year;
	}



	public Integer getState()
	{
		return state;
	}



	public void setState(Integer state)
	{
		this.state = state;
	}



	public Integer getLevel()
	{
		return level;
	}



	public void setLevel(Integer level)
	{
		this.level = level;
	}



	public String getProjectFileno()
	{
		return projectFileno;
	}



	public void setProjectFileno(String projectFileno)
	{
		this.projectFileno = projectFileno;
	}



	public String getLegalMan()
	{
		return legalMan;
	}



	public void setLegalMan(String legalMan)
	{
		this.legalMan = legalMan;
	}



	public String getTechLeader()
	{
		return techLeader;
	}



	public void setTechLeader(String techLeader)
	{
		this.techLeader = techLeader;
	}



	public String getUnitName()
	{
		return unitName;
	}



	public void setUnitName(String unitName)
	{
		this.unitName = unitName;
	}



	public Integer getFundType()
	{
		return fundType;
	}



	public void setFundType(Integer fundType)
	{
		this.fundType = fundType;
	}



	public Long getGrantFunds()
	{
		return grantFunds;
	}



	public void setGrantFunds(Long grantFunds)
	{
		this.grantFunds = grantFunds;
	}



	public Long getOtherFunds()
	{
		return otherFunds;
	}



	public void setOtherFunds(Long otherFunds)
	{
		this.otherFunds = otherFunds;
	}



	public Long getSelfRaisedFunds()
	{
		return selfRaisedFunds;
	}



	public void setSelfRaisedFunds(Long selfRaisedFunds)
	{
		this.selfRaisedFunds = selfRaisedFunds;
	}



	public Long getTotalFunds()
	{
		return totalFunds;
	}



	public void setTotalFunds(Long totalFunds)
	{
		this.totalFunds = totalFunds;
	}



	public String getCountyRecFileno()
	{
		return countyRecFileno;
	}



	public void setCountyRecFileno(String countyRecFileno)
	{
		this.countyRecFileno = countyRecFileno;
	}



	public String getCityRecFileno()
	{
		return cityRecFileno;
	}



	public void setCityRecFileno(String cityRecFileno)
	{
		this.cityRecFileno = cityRecFileno;
	}



	public String getIntro()
	{
		return intro;
	}



	public void setIntro(String intro)
	{
		this.intro = intro;
	}



	public Date getCreateTime()
	{
		return createTime;
	}



	public void setCreateTime(Date createTime)
	{
		this.createTime = createTime;
	}



	public Date getCommitTime()
	{
		return commitTime;
	}



	public void setCommitTime(Date commitTime)
	{
		this.commitTime = commitTime;
	}



	public Date getCountyRecTime()
	{
		return countyRecTime;
	}



	public void setCountyRecTime(Date countyRecTime)
	{
		this.countyRecTime = countyRecTime;
	}



	public Date getCityRecTime()
	{
		return cityRecTime;
	}



	public void setCityRecTime(Date cityRecTime)
	{
		this.cityRecTime = cityRecTime;
	}



	public Date getProvinceRecTime()
	{
		return provinceRecTime;
	}



	public void setProvinceRecTime(Date provinceRecTime)
	{
		this.provinceRecTime = provinceRecTime;
	}



	public Date getAuditTime()
	{
		return auditTime;
	}



	public void setAuditTime(Date auditTime)
	{
		this.auditTime = auditTime;
	}



	public Area getCounty()
	{
		return county;
	}



	public void setCounty(Area county)
	{
		this.county = county;
	}



	public Area getCity()
	{
		return city;
	}



	public void setCity(Area city)
	{
		this.city = city;
	}



	public ProjectClass getProjectClass()
	{
		return projectClass;
	}



	public void setProjectClass(ProjectClass projectClass)
	{
		this.projectClass = projectClass;
	}



	public User getDeclareUser()
	{
		return declareUser;
	}



	public void setDeclareUser(User declareUser)
	{
		this.declareUser = declareUser;
	}



	public User getCountyRecUser()
	{
		return countyRecUser;
	}



	public void setCountyRecUser(User countyRecUser)
	{
		this.countyRecUser = countyRecUser;
	}



	public User getCityRecUser()
	{
		return cityRecUser;
	}



	public void setCityRecUser(User cityRecUser)
	{
		this.cityRecUser = cityRecUser;
	}



	public User getProvinceRecUser()
	{
		return provinceRecUser;
	}



	public void setProvinceRecUser(User provinceRecUser)
	{
		this.provinceRecUser = provinceRecUser;
	}



	public User getAuditUser()
	{
		return auditUser;
	}



	public void setAuditUser(User auditUser)
	{
		this.auditUser = auditUser;
	}
	
}
